package com.xbai.bean;

import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

/**
 * @author xbai
 * @Date 2021/3/30
 */
public class LifeCycleBean implements InitializingBean, DisposableBean {

    public LifeCycleBean() {
        System.out.println("LifeCycleBean...constructor...");
    }

    public void initMethod() {
        System.out.println("LifeCycleBean...initMethod...");
    }

    public void destroyMethod() {
        System.out.println("LifeCycleBean...destroyMethod...");
    }

    @Override
    public void destroy() throws Exception {
        System.out.println("LifeCycleBean...DisposableBean...destroy...");
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("LifeCycleBean...InitializingBean...afterPropertiesSet...");
    }

    @PostConstruct
    public void postConstruct() {
        System.out.println("LifeCycleBean...PostConstruct....");
    }

    @PreDestroy
    public void preDestroy() {
        System.out.println("LifeCycleBean...PreDestroy...");
    }
}
